import express from 'express';
import * as sign from '../service/sign';
import * as user from '../service/user';
// 校验文件以及API文档
const Route = express.Router();

Route.route('/sign/:id').post(async (req, res) => {
	try {
		const result = await sign.update({ data: req.params });
		const userInfo = await user.selectById({id: req.params.id})
		if (result.code !== 1 || !userInfo.data[0]) {
			baseResponse(req, res, { code: 4, message: '资源未找到~' });
		} else {
			baseResponse(req, res, {
				code: 1,
				message: '签到成功~',
				data: userInfo.data[0]
			});
		}
	} catch (error) {
		baseResponse(req, res, { code: -1, message: error });
		console.log(error);
	}
});

export default Route;
